package org.yenn.pattern.aliyun.j2ee.Interceptingfilter;

import lombok.Setter;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author: yerenyun
 * @Description: 步骤 4 创建过滤器链。
 */
public class FilterChain<T> {
    private List<Filter> filters = new ArrayList();
    @Setter
    private Target target;

    public void addFilter(Filter filter) {
        filters.add(filter);
    }

    public void execute(String request) {
        for (Filter filter : filters) {
            filter.execute(request);
        }
        target.execute(request);
    }

}